﻿@model IEnumerable<MMSWebsite.Models.EmployeeViewModel>

<table>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.Employee.Name)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Employee.Code)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Employee.Sex)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Employee.Phone)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Employee.Email)
            </th>
            <th>
                 @Html.DisplayName("Address")
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Roles)
            </th>
            <th> @Html.DisplayName("State") </th>
            <th></th>
        </tr>
    
        @{
            var OddColor = "#DDEEEE";
            var evenColor = "#EEFFFF";
            var Odd = OddColor;
            var BlackColor = "Black";
            var RedColor = "Red";
            var TextColor = BlackColor;
        }
        @foreach (var item in Model) {
            TextColor = item.Employee.IsLocked == true ? RedColor : BlackColor;
            <tr bgcolor="@Odd" style="color: @TextColor">
                <td style="font-weight: bold">
                    @Html.DisplayFor(modelItem => item.Employee.Name)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Employee.Code)
                </td>
                <td>
                    @if (item.Employee.Sex == true)
                    {
                        @: Male
                    }
                    else
                    {
                        @: Female
                    }
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Employee.Phone)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Employee.Email)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Employee.NumberAddress),  
                    @Html.DisplayFor(modelItem => item.Employee.Area.DistrictName), 
                    @Html.DisplayFor(modelItem => item.Employee.Area.CityName)
                </td>
                <td>
                    @foreach (var role in item.Roles.Where(role => role.RoleIsChecked == true))
                    {
                        @Html.DisplayFor(modelRole => role.Role.RoleName)
                        @:,
                    }
                </td>
                <td style="text-align: center">
                    @if (item.Employee.IsLocked == true)
                    {
                        <img src="~/Images/Locked.png" width="30px" height="30px" />
                    }
                    else
                    {
                        <img src="~/Images/Running.png" width="30px" height="30px" />
                    }
                </td>
                <td style="text-align: center">
                    @Html.ActionLink("Edit", "Edit", new {id = item.Employee.Id}) |
                    @Html.ActionLink("Details", "Details", new {id = item.Employee.Id})
                </td>
            </tr>
            Odd = Odd == OddColor ? evenColor : OddColor;
        
        }

    </table>